Skip to content

Fix GetRoundFromTenderbakeBlock error handling and validation#16

Merged
jevonearth merged 1 commit intov2from
fix/getround-fitness-error-handling
Mar 3, 2026
Merged

Fix GetRoundFromTenderbakeBlock error handling and validation#16
jevonearth merged 1 commit intov2from
fix/getround-fitness-error-handling

Conversation

@jevonearth
Copy link
Copy Markdown
Contributor

Summary

Followup to #13. Addresses two issues in the contributed GetRoundFromTenderbakeBlock and its caller:

  • BlockSignRequest.GetRound() swallowed errors with fmt.Println and silently returned round 0. Replaced with panic, matching the existing convention for impossible-state failures in the other GetRound() methods (preattestation/attestation). Round 0 is a valid value, so silent failure here could cause incorrect watermark decisions in Signatory.

  • Fitness length validation was too weak (< 4 bytes). Tightened to < 33, the minimum valid Tenderbake fitness (without locked round). Previously, any 4+ byte input would be accepted as valid fitness.

Also adds TestGetRoundFromTenderbakeBlock with:

  • Two real mainnet fitness vectors (proto_016 level 3365599 round 0, proto_024 level 12169657 round 1 reproposal)
  • Both fitness shapes (with/without locked round)
  • Error rejection for truncated/empty input

Test plan

  • go test ./protocol/core/ -run TestGetRoundFromTenderbakeBlock -v passes
  • go vet ./protocol/... clean
  • go build ./protocol/... clean

- Replace fmt.Println error swallowing with panic in
  BlockSignRequest.GetRound(), matching existing convention for
  impossible-state failures in consensus sign request methods.
  The previous behavior silently returned round 0 on error.

- Tighten fitness length check from 4 to 33 bytes (minimum valid
  Tenderbake fitness without locked round).

- Add tests with two real mainnet fitness vectors (proto_016 round 0,
  proto_024 round 1 reproposal) plus synthetic coverage for both
  fitness shapes and error rejection.

Followup to #13.
@jevonearth jevonearth merged commit 4286a97 into v2 Mar 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant